<template>
  <div class="confirm"  :class="{ fade }">
    <div class="wrapper" :class="{ fade }">
      <div class="confirm-context">
        {{text}}
      </div>
      <div class="footer">
          <div class="btn-cancel" v-if="cancelStaus" @click.stop="cancelCallback"></div>
          <div class="btn-confim" @click.stop="submitCallback"></div>
      </div>
    </div>
  </div>
</template>
<script>
import { onMounted, ref } from "vue";
export default {
  name: "Confirm",
  props: {
    title: {
      type: String,
      default: ""
    },
    text: {
      type: String,
      default: ""
    },
    submitCallback: {
      type: Function // 确认事件
    },
    cancelCallback: {
      type: Function // 取消事件
    },
    cancelStaus:{
      type:Boolean,
      default:true
    }
  },
  setup(props) {
    const fade = ref(false)
    onMounted(() => {
      setTimeout(() => {
        fade.value = true
      }, 0)
    })
    return { fade }
  },
  components: { }
}
</script>

<style lang="scss" scoped>
.confirm {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 8888;
  background: rgba(0, 0, 0, 0);
  &.fade {
    transition: all 0.4s;
    background: rgba(0, 0, 0, 0.5);
  }
  .wrapper {
    width: 500px;
    background-image: url(/images/dgbg4.png);
    background-position: center;
    background-repeat: no-repeat;
    background-size:100% 100%;
    border-radius: 4px;
    position: absolute;
    padding:30px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    opacity: 0;
    &.fade {
      transition: all 0.4s;
      transform: translate(-50%, -50%);
      opacity: 1;
    }

    .footer {
      margin: 10px 20px;
      display: flex;
      justify-content: space-around;
      position: relative;
       height:60px;
      .btn-confim,
      .btn-cancel{
            background-image: url(/images/adRelease/btn-confim.png);
            background-position: center;
            background-repeat: no-repeat;
            background-size:100% 100%;
            height:60px;
            width:160px;
      }
      .btn-cancel{
        background-image: url(/images/adRelease/grid-cancel.png);
      }
    }
    .confirm-context {
      padding-bottom:20px;
      font-size: 24px;
      .icon-warning {
        color: #ff0000;
        margin-right: 3px;
        font-size: 16px;
      }
    }
  }
}
</style>
